package com.approval.approval;

import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.approval.approvalapp.R;
import com.approval.approvalapp.center.adapter.BaseRecycleListAdapter;
import com.approval.approvalapp.center.adapter.QjkgAdapter;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

public class QjkgAdapter2  extends BaseRecycleListAdapter<QjkgBean.LeaveTodayBean> {

    public QjkgAdapter2(List<QjkgBean.LeaveTodayBean> mList, Context context) {
        super(mList, context);
    }

    @Override
    public int getLayoutId() {
        return R.layout.qjkg_item;
    }

    @Override
    public RecyclerView.ViewHolder createHolder(View view) {
        return new ViewHolder(view);
    }

    @Override
    protected void onBindDefaultViewHolder(RecyclerView.ViewHolder holder, QjkgBean.LeaveTodayBean bean, int position) {
        if(holder instanceof ViewHolder){
            ((ViewHolder) holder).setData(bean);
        }
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        @Bind(R.id.tv_name)
        TextView tvName;
        @Bind(R.id.tv_province)
        TextView tvProvince;
        @Bind(R.id.tv_state)
        TextView tvState;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

        public void setData(QjkgBean.LeaveTodayBean bean) {

            tvName.setText(bean.getTitle());
            tvProvince.setText(bean.getCode());
//            int stateT = bean.getStateT();
//            if(stateT == 4){
//                tvState.setText("状态：旷工");
//                tvState.setBackgroundResource(R.drawable.blueshape4_11);
//                tvState.setTextColor(Color.parseColor("#1076FF"));
//            } else {
                tvState.setText("状态：请假");
                tvState.setBackgroundResource(R.drawable.blueshape4_11);
                tvState.setTextColor(Color.parseColor("#1076FF"));
//            }
        }
    }
}
